﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGameAula02
{
    class Shot: AnimatedObject2D
    {
        private Vector2 dir;
        private float speed;
        public float creationTime;
        
        public Shot(Texture2D image, Vector2 position, float rotation, float speed, float time, Animation[] a)
            : base(image, position, a)
        {
            this.Rotation = rotation;
            this.dir = new Vector2((float)Math.Sin(rotation), -(float)Math.Cos(rotation));
            this.speed = (Math.Abs(speed) + 1f) * 2;
            creationTime = time;
            Origin = new Vector2(a[0].FrameSize.X / 2, a[0].FrameSize.X / 2);
            Rect = new Rectangle(0, 0, (int)a[0].FrameSize.X, (int)a[0].FrameSize.X);
            Scale = Vector2.One;
            LayerDepth = 0f;
            Effects = SpriteEffects.None;
            Cor = Color.White;
        }

        public void UpdatePosition()
        {
            Position += dir*speed;
        }
    }
}
